<?php
class Pageley_Imaging_Shape_RoundedRectangleTests extends Pageley_Test_Case {
    public function testDrawColor() {
        $image = new Pageley_Imaging_Image(100, 100);
        $brush = new Pageley_Imaging_Brush_Color(0xFF, 0x00, 0x00, 0x80);
        $shape = new Pageley_Imaging_Shape_RoundedRectangle(30, 50, 5);
        $image->draw($shape, $brush, 20, 10);
        $image->toFile(new Pageley_Util_File("config/roundedRectangleColor.png"), "image/png");
        $transparent = Pageley_Imaging_Brush_Color::$TRANSPARENT;
        $this->assertEquals($transparent, $image->colorAt(21, 11));
        $this->assertEquals($brush, $image->colorAt(22, 12));
        $this->assertEquals($brush, $image->colorAt(47, 57));
        $this->assertEquals($transparent, $image->colorAt(48, 58));
    }
    
    public function testDrawTexture() {
        $image = new Pageley_Imaging_Image(100, 100);
        $textureImage = Pageley_Imaging_Image::fromFile(new Pageley_Util_File("config/texture.png"));
        $brush = new Pageley_Imaging_Brush_Texture($textureImage);
        $shape = new Pageley_Imaging_Shape_RoundedRectangle(30, 50, 5);
        $image->draw($shape, $brush, 20, 10);
        $image->toFile(new Pageley_Util_File("config/roundedRectangleTexture.png"), "image/png");
        $transparent = Pageley_Imaging_Brush_Color::$TRANSPARENT;
        $color1 = Pageley_Imaging_Brush_Color::fromHex("#6d6d6d");
        $color2 = Pageley_Imaging_Brush_Color::fromHex("#a7a7a7");
        $this->assertEquals($transparent, $image->colorAt(21, 11));
        $this->assertEquals($color1, $image->colorAt(22, 12));
        $this->assertEquals($color2, $image->colorAt(47, 57));
        $this->assertEquals($transparent, $image->colorAt(48, 58));
    }
}